package ch5;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;

public class Money {

	public static void main(String[] args) throws IOException {
		System.setOut(new PrintStream(new File("D:/1.txt")));
		//
		int money = 100;
		// int m100, m50, m20, m10, m5, m2, m1;
		for (int m100 = 0; m100 <= money / 100; m100++) {
			for (int m50 = 0, t50 = (money - 100 * m100) / 50; m50 <= t50; m50++) {
				for (int m20 = 0; m20 <= (money - 100 * m100 - m50 * 50) / 20; m20++) {
					for (int m10 = 0; m10 <= (money - 100 * m100 - m50 * 50 - m20 * 20) / 10; m10++) {
						for (int m5 = 0; m5 <= (money - 100 * m100 - m50 * 50 - m20 * 20 - m10 * 10) / 5; m5++) {
							for (int m2 = 0; m2 <= (money - 100 * m100 - m50 * 50 - m20 * 20 - m10 * 10 - m5 * 5)
									/ 2; m2++) {
								int m1 = money - 100 * m100 - m50 * 50 - m20 * 20 - m10 * 10 - m5 * 5 - m2 * 2;
								System.out.print("需要：");
								System.out.print(m100 == 0 ? "" : (m100 + "张100元  "));
								System.out.print(m50 == 0 ? "" : (m50 + "张50元  "));
								System.out.print(m20 == 0 ? "" : (m20 + "张20元  "));
								System.out.print(m10 == 0 ? "" : (m10 + "张10元  "));
								System.out.print(m5 == 0 ? "" : (m5 + "张5元  "));
								System.out.print(m2 == 0 ? "" : (m2 + "张2元  "));
								System.out.print(m1 == 0 ? "" : (m1 + "张1元  "));
								System.out.println();
							}
						}
					}
				}
			}
		}
	}

}
